package per.songyu.pj.goods.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import per.songyu.pj.goods.dao.GoodsDao;
import per.songyu.pj.goods.pojo.Goods;
import per.songyu.pj.goods.service.GoodsService;

/**
 * 商品业务层对象，负责业务逻辑处理。
 * @author qilei
 */

@Service
public class GoodsServiceImpl implements GoodsService {
    //has a
    @Autowired
    private GoodsDao goodsDao;


    @Override
    public List<Goods> findGoods() {
        long start=System.currentTimeMillis();
        List<Goods> list=goodsDao.findObjects();
        long end=System.currentTimeMillis();
        System.out.println("query time:"+(end-start));
        return list;
    }

    @Override
    public int doDeleteById(Integer id) {
        return goodsDao.deleteById(id);

    }

    @Override
    public int saveGoods(Goods entity) {
        return goodsDao.insert(entity);
    }

    @Override
    public Goods findGoodsById(int id) {
        return goodsDao.findGoodsById(id);
    }

    @Override
    public int doUpdateById(Goods goods) {
        return goodsDao.updateById(goods);
    }
}
